Expoloring data


Filtering counts

Figure 1: Size factors of initial oyster samples in the study, calculated using oyster gene count data.

After viewing the size factors, it appears that we have 5 samples with really low values that should be removed:

  • 19355
  • 19372
  • 19382
  • 19496
  • 19505


Figure 2: Size factors of oyster samples remaining in the study after 5 outliers were removed, calculated using oyster gene count data.

Without filtering low reads, we had a total of 38828 counts. After filtering out the low counts (those with a base mean less than 3), we now have 24384 counts remaining for all C. virginica samples.



PCA plots of Global Gene Expression

# going to use the filter_counts_out object created above because it is filtered for low reads and has outliers removed

## create the DESeq object
dds <- DESeqDataSetFromMatrix(countData = filter_counts_out, 
                              colData = expDesign,
                              design = ~ treat)
dds <- DESeq(dds) # differential expression analysis on gamma-poisson distribution
vsd <- varianceStabilizingTransformation(dds, blind = TRUE) # quickly estimate dispersion trend and apply a variance stabilizing transformation

## saving the rlog for DEG heatmap
rlog <- DESeq2::rlog(dds, blind = TRUE) #for use later on


## Save dds and vsd data 
save(dds, vsd, rlog, file = "Data/transformed_counts.RData")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 1500
## 
## adonis2(formula = pcaData[6:31] ~ pcaData$infect * pcaData$pCO2, permutations = 1500, method = "eu")
##                             Df SumOfSqs      R2      F Pr(>F)
## pcaData$infect               1   1118.3 0.04736 1.1893 0.1799
## pcaData$pCO2                 1    945.3 0.04003 1.0053 0.3817
## pcaData$infect:pcaData$pCO2  1    864.0 0.03659 0.9188 0.5623
## Residual                    22  20686.8 0.87603              
## Total                       25  23614.3 1.00000


Figure 3: PCA plot with each point being one oyster sample colored by treatment. Orange represents the control treatment (no boring sponge, pCO2 level 400), green represents no sponge, pCO2 level 2800, purple represents samples infected with boring sponge at pCO2 2800, and pink represents samples infected with boring sponge at pCO2 400.



Differential gene expression


DEGs

## log2 fold change (MLE): treat S 400 vs N 2800 
## Wald test p-value: treat S 400 vs N 2800 
## DataFrame with 24384 rows and 6 columns
##               baseMean log2FoldChange     lfcSE       stat    pvalue      padj
##              <numeric>      <numeric> <numeric>  <numeric> <numeric> <numeric>
## LOC111126949  3.452259     -0.9422247  0.817784 -1.1521686  0.249252  0.999652
## LOC111110729  0.485466     -0.5124481  1.463646 -0.3501175  0.726251  0.999652
## LOC111120752  1.693621     -0.2827063  0.846812 -0.3338478  0.738494  0.999652
## LOC111113860  5.933380     -0.0448271  0.601266 -0.0745544  0.940569  0.999652
## LOC111109550  0.331392     -0.9860539  2.483653 -0.3970176  0.691355  0.999652
## ...                ...            ...       ...        ...       ...       ...
## LOC111117112 0.6463025      1.6788746   1.80337  0.9309629  0.351873  0.999652
## LOC111117113 0.1436384      0.7681374   3.83879  0.2000987  0.841403  0.999652
## LOC111117117 0.0778208      0.2872407   4.24705  0.0676329  0.946078  0.999652
## LOC111116908 0.1097457     -0.0817811   4.24580 -0.0192617  0.984632  0.999652
## LOC111117715 0.6210268     -0.4455042   1.67997 -0.2651862  0.790866  0.999652
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.1
## LFC > 0 (up)       : 2, 0.0082%
## LFC < 0 (down)     : 0, 0%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 3, 0.012%
## (mean count < 0)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
summary(res_con_sponge)
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.05
## LFC > 0 (up)       : 0, 0%
## LFC < 0 (down)     : 0, 0%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 3, 0.012%
## (mean count < 0)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
summary(res_con_pco2)
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.05
## LFC > 0 (up)       : 0, 0%
## LFC < 0 (down)     : 0, 0%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 3, 0.012%
## (mean count < 0)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
summary(res_trt)
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.05
## LFC > 0 (up)       : 6, 0.025%
## LFC < 0 (down)     : 5, 0.021%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 11339, 47%
## (mean count < 2)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
summary(res_trt_pco2)
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.05
## LFC > 0 (up)       : 3, 0.012%
## LFC < 0 (down)     : 5, 0.021%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 14166, 58%
## (mean count < 3)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
summary(res_stn_pco2)
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.05
## LFC > 0 (up)       : 2, 0.0082%
## LFC < 0 (down)     : 0, 0%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 3, 0.012%
## (mean count < 0)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
summary(res_shn_pco2)
## 
## out of 24380 with nonzero total read count
## adjusted p-value < 0.05
## LFC > 0 (up)       : 1, 0.0041%
## LFC < 0 (down)     : 3, 0.012%
## outliers [1]       : 36, 0.15%
## low counts [2]     : 3, 0.012%
## (mean count < 0)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
## [1] "N_400, S_2800"

Figure: Bar plot of significant DEGs. The y axis denotes how many genes there are, with positive values being up-regulated genes, and negative values denoting down-regulated genes.



Paired Venns of DEGs

Figure 4: Venn diagrams depicting number of shared significantly up-regulated / down-regulated genes. Orange venn diagrams depict up-regulated genes, while blue depicts down-regulated genes.



Full Venns of DEGs

Need to add all treatments with DEGs to the below code (ANGELA)

Figure 5: left: four-way venn diagram showing relationships among up-regulated genes between different treatment comparisons. right: venn diagram showing relationships among down-regulated genes between treatment comparisons with significantly down-regulated genes.



Gene expression plasticity



ANOVA Tests on Plasticity Data

ANOVA test on plasticity data with 2 PCAs (looking at variable treat to see if there is any significant difference of dist)

##             Df Sum Sq Mean Sq F value Pr(>F)
## treat        2  348.9  174.44   1.835   0.19
## Residuals   17 1616.2   95.07
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = dist ~ treat, data = ge_plast_2)
## 
## $treat
##                    diff        lwr      upr     p adj
## S_2800-N_2800  9.903288  -3.466771 23.27335 0.1689911
## S_400-N_2800   6.107834  -7.808165 20.02383 0.5117339
## S_400-S_2800  -3.795455 -17.711454 10.12054 0.7668884

ANOVA test on plasticity data with all PCAs (looking at variable treat to see if there is any significant difference of dist)

##             Df Sum Sq Mean Sq F value Pr(>F)
## treat        2   89.9   44.96   1.967   0.17
## Residuals   17  388.6   22.86
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = dist ~ treat, data = ge_plast_all)
## 
## $treat
##                    diff       lwr       upr     p adj
## S_2800-N_2800  4.993713 -1.562429 11.549855 0.1542649
## S_400-N_2800   3.289942 -3.533907 10.113791 0.4485889
## S_400-S_2800  -1.703771 -8.527620  5.120078 0.8000952



ANOVA test on plasticity data with all PCAs (looking at variable pCO2 * infect to see if there is any significant difference of dist)

##             Df Sum Sq Mean Sq F value Pr(>F)  
## pCO2         1    2.6    2.64   0.116 0.7381  
## infect       1   87.3   87.28   3.818 0.0674 .
## Residuals   17  388.6   22.86                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Call:
##    aov(formula = dist ~ pCO2 * infect, data = ge_plast_all)
## 
## Terms:
##                     pCO2   infect Residuals
## Sum of Squares    2.6417  87.2801  388.6136
## Deg. of Freedom        1        1        17
## 
## Residual standard error: 4.781174
## 1 out of 4 effects not estimable
## Estimated effects may be unbalanced
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = dist ~ pCO2 * infect, data = ge_plast_all)
## 
## $pCO2
##                diff      lwr     upr     p adj
## 2800-400 -0.7930852 -5.71523 4.12906 0.7380613
## 
## $infect
##         diff       lwr      upr     p adj
## S-N 3.841318 -0.887726 8.570362 0.1047456



ANOVA test on plasticity data with all PCAs (looking at variable pCO2 * infect to see if there is any significant difference of dist)

##             Df Sum Sq Mean Sq F value Pr(>F)  
## pCO2         1    5.6     5.6   0.059 0.8109  
## infect       1  343.3   343.3   3.611 0.0745 .
## Residuals   17 1616.2    95.1                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Call:
##    aov(formula = dist ~ pCO2 * infect, data = ge_plast_2)
## 
## Terms:
##                      pCO2    infect Residuals
## Sum of Squares     5.6144  343.2629 1616.1736
## Deg. of Freedom         1         1        17
## 
## Residual standard error: 9.750335
## 1 out of 4 effects not estimable
## Estimated effects may be unbalanced
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = dist ~ pCO2 * infect, data = ge_plast_2)
## 
## $pCO2
##               diff       lwr     upr     p adj
## 2800-400 -1.156189 -11.19401 8.88163 0.8109013
## 
## $infect
##         diff       lwr      upr     p adj
## S-N 7.617914 -2.026111 17.26194 0.1139175



ANOVA test on plasticity data with all PCAs (looking at variable treat to see if there is any significant difference of dist)

##             Df Sum Sq Mean Sq F value Pr(>F)
## treat        2   89.9   44.96   1.967   0.17
## Residuals   17  388.6   22.86
## Call:
##    aov(formula = dist ~ treat, data = ge_plast_all)
## 
## Terms:
##                    treat Residuals
## Sum of Squares   89.9218  388.6136
## Deg. of Freedom        2        17
## 
## Residual standard error: 4.781174
## Estimated effects may be unbalanced
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = dist ~ treat, data = ge_plast_all)
## 
## $treat
##                    diff       lwr       upr     p adj
## S_2800-N_2800  4.993713 -1.562429 11.549855 0.1542649
## S_400-N_2800   3.289942 -3.533907 10.113791 0.4485889
## S_400-S_2800  -1.703771 -8.527620  5.120078 0.8000952



Plasticity Plots

Figure 6: Assessment of plasticity (A-D) calculated as the average of the distances of each sample to the mean eigenvalue of the control (N_400). The control was omitted from this analysis. A) and C) pertains to analysis of all PCAs, while B) and D) contain analysis of 2 PCAs. A-B depicts box plots of plasticity and each individual sample as a point, while C-D shows the mean and standard error.

Results

Infected oyster samples in the 2800 pCO2 treatment exhibited the highest plasticity (Figure __), but results from the ANOVA test with all PCAs suggest this was not statistically significant (p = 0.17, F = .967). Oysters not infected with sponge and in the 2800 treatment had the lowest plasticity (Figure _).



GO for DESeq

Figure SX

All significant GO terms identified from DEGs:

BP_DEG_tree:BP_DEG_tree CC_DEG_tree:CC_DEG_tree MF_DEG_tree:MF_DEG_tree

Example of a heatmap for a GO term

Trying Dan’s way…

All the other heatmaps!



Colleen adding in WGCNA

##  Flagging genes and samples with too many missing values...
##   ..step 1
## [1] TRUE



Session Information

Session information from the last full knit of Rmarkdown on 12 July 2022.

## R version 4.2.0 (2022-04-22)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur/Monterey 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] grid      stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] pheatmap_1.0.12             RColorBrewer_1.1-3         
##  [3] gplots_3.1.3                WGCNA_1.71                 
##  [5] fastcluster_1.2.3           dynamicTreeCut_1.63-1      
##  [7] flashClust_1.01-2           ggvenn_0.1.9               
##  [9] adegenet_2.1.7              ade4_1.7-19                
## [11] ggrepel_0.9.1               pdftools_3.2.1             
## [13] ggpubr_0.4.0                data.table_1.14.2          
## [15] vegan_2.6-2                 lattice_0.20-45            
## [17] permute_0.9-7               DESeq2_1.36.0              
## [19] SummarizedExperiment_1.26.1 Biobase_2.56.0             
## [21] MatrixGenerics_1.8.1        matrixStats_0.62.0         
## [23] GenomicRanges_1.48.0        GenomeInfoDb_1.32.2        
## [25] IRanges_2.30.0              S4Vectors_0.34.0           
## [27] BiocGenerics_0.42.0         plotly_4.10.0              
## [29] forcats_0.5.1               stringr_1.4.0              
## [31] dplyr_1.0.9                 purrr_0.3.4                
## [33] readr_2.1.2                 tidyr_1.2.0                
## [35] tibble_3.1.7                ggplot2_3.3.6              
## [37] tidyverse_1.3.1             knitr_1.39                 
## 
## loaded via a namespace (and not attached):
##   [1] utf8_1.2.2             tidyselect_1.1.2       RSQLite_2.2.14        
##   [4] AnnotationDbi_1.58.0   htmlwidgets_1.5.4      BiocParallel_1.30.3   
##   [7] munsell_0.5.0          codetools_0.2-18       preprocessCore_1.58.0 
##  [10] withr_2.5.0            colorspace_2.0-3       highr_0.9             
##  [13] rstudioapi_0.13        ggsignif_0.6.3         labeling_0.4.2        
##  [16] GenomeInfoDbData_1.2.8 bit64_4.0.5            farver_2.1.0          
##  [19] vctrs_0.4.1            generics_0.1.2         xfun_0.31             
##  [22] qpdf_1.2.0             R6_2.5.1               doParallel_1.0.17     
##  [25] locfit_1.5-9.5         bitops_1.0-7           cachem_1.0.6          
##  [28] DelayedArray_0.22.0    assertthat_0.2.1       promises_1.2.0.1      
##  [31] scales_1.2.0           vroom_1.5.7            nnet_7.3-17           
##  [34] gtable_0.3.0           rlang_1.0.2            genefilter_1.78.0     
##  [37] splines_4.2.0          rstatix_0.7.0          lazyeval_0.2.2        
##  [40] impute_1.70.0          broom_0.8.0            checkmate_2.1.0       
##  [43] yaml_2.3.5             reshape2_1.4.4         abind_1.4-5           
##  [46] modelr_0.1.8           backports_1.4.1        httpuv_1.6.5          
##  [49] Hmisc_4.7-0            tools_4.2.0            ellipsis_0.3.2        
##  [52] jquerylib_0.1.4        Rcpp_1.0.8.3           plyr_1.8.7            
##  [55] base64enc_0.1-3        zlibbioc_1.42.0        RCurl_1.98-1.7        
##  [58] rpart_4.1.16           cowplot_1.1.1          haven_2.5.0           
##  [61] cluster_2.1.3          fs_1.5.2               magrittr_2.0.3        
##  [64] reprex_2.0.1           hms_1.1.1              mime_0.12             
##  [67] evaluate_0.15          xtable_1.8-4           XML_3.99-0.10         
##  [70] jpeg_0.1-9             readxl_1.4.0           gridExtra_2.3         
##  [73] compiler_4.2.0         KernSmooth_2.23-20     crayon_1.5.1          
##  [76] htmltools_0.5.2        mgcv_1.8-40            later_1.3.0           
##  [79] tzdb_0.3.0             Formula_1.2-4          geneplotter_1.74.0    
##  [82] lubridate_1.8.0        DBI_1.1.3              dbplyr_2.2.1          
##  [85] MASS_7.3-57            Matrix_1.4-1           car_3.1-0             
##  [88] cli_3.3.0              parallel_4.2.0         igraph_1.3.2          
##  [91] pkgconfig_2.0.3        foreign_0.8-82         xml2_1.3.3            
##  [94] foreach_1.5.2          annotate_1.74.0        bslib_0.3.1           
##  [97] XVector_0.36.0         rvest_1.0.2            digest_0.6.29         
## [100] Biostrings_2.64.0      rmarkdown_2.14         cellranger_1.1.0      
## [103] htmlTable_2.4.0        shiny_1.7.1            gtools_3.9.2.2        
## [106] lifecycle_1.0.1        nlme_3.1-158           jsonlite_1.8.0        
## [109] carData_3.0-5          seqinr_4.2-16          viridisLite_0.4.0     
## [112] askpass_1.1            fansi_1.0.3            pillar_1.7.0          
## [115] KEGGREST_1.36.2        fastmap_1.1.0          httr_1.4.3            
## [118] survival_3.3-1         GO.db_3.15.0           glue_1.6.2            
## [121] png_0.1-7              iterators_1.0.14       bit_4.0.4             
## [124] stringi_1.7.6          sass_0.4.1             blob_1.2.3            
## [127] latticeExtra_0.6-29    caTools_1.18.2         memoise_2.0.1         
## [130] ape_5.6-2